package com.fenghongzhang.day014;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;

public class MyService extends Service {

    private static final String TAG = "MyService";

    public MyService() {
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Log.i(TAG, "onCreate: ");
        //定时器
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.i(TAG, "onStartCommand: ");
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.i(TAG, "onDestroy: ");
    }



    class MyBinder extends Binder{
        public void callPlay(){
            play();
        }
        public void callNext(String s){
            next(s);
        }
    }

    @Override
    public IBinder onBind(Intent intent) {
        Log.i(TAG, "onBind: ");
        return new MyBinder();
    }


    @Override
    public boolean onUnbind(Intent intent) {
        //释放资源
        Log.i(TAG, "onUnbind: ");
        return super.onUnbind(intent);
    }


    public void play(){
        Log.i(TAG, "play: ");
    }

    public void next(String s){
        Log.i(TAG, "next: " + s);
    }
}
